import http from '@/utils/http'

interface BasicParams {
    dtoName: string // 参考后端接口文档
    queryId: string // 参考confluence上的页面需求SQL标识
    version: string // 参考confluence上的页面需求SQL版本号
    menuName: string // 菜单的标识，与菜单管理配置保持一致
    usage: string // 接口后缀，标识用途
}
/*
  eg./ims-tworkgz-service/viewCstHistory/getCstHistory
*/

/** 获取 recipeName信息 */
export function getRecipeName({
  eqpId, operation, operationVer, productId, route, routeVer, shopId
}: {eqpId: string, operation: string, operationVer: string, productId: string, route: string, routeVer: string, shopId: string }): Promise<any> {
  const data = {
    dtoName: 'RecipeNameDTO',
    queryId: 'GetRecipeList',
    version: '80009',
    eqpId,
    operation,
    operationVer,
    productId,
    route,
    routeVer,
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/recipeIdSetting/getRecipeName',
    method: 'POST',
    data
  })
}

/** 获取 recipeName信息 */
export function getEqpList({
  operation, operationVer, productId, productVer, route, routeVer, shopId
}: {eqpId: string, operation: string, operationVer: string, productId: string, productVer:string, route: string, routeVer: string, shopId: string }): Promise<any> {
  const data = {
    dtoName: 'ChangeMachineRunModeEqpIdDTO',
    queryId: 'GetMachineList',
    version: '80049',
    operation,
    operationVer,
    productId,
    productVer,
    route,
    routeVer,
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/recipeIdSetting/getEqpList',
    method: 'POST',
    data
  })
}
/** 获取 recipeIdSetting 增删改  */
export function AddOrUpdateDelete({
  actionType, eqpId, eventUser, language, operation, productId, productVer, recipeName, route, valiCode, valiResult
}: {actionType:string, eqpId: string, eventUser:string, language:string, operation: string, productId: string, productVer:string, recipeName:string, route: string, valiCode: string, valiResult: string }): Promise<any> {
  const data = {
    actionType,
    eqpId,
    eventUser,
    language,
    operation,
    productId,
    productVer,
    recipeName,
    route,
    valiCode,
    valiResult
  }
  return http.request({
    url: '/ims-tworkgz-service/recipeIdSetting/addOrUpdateOrDelete',
    method: 'POST',
    data
  })
}
